package com.mcx.modules.generation.domain;

import lombok.Data;
import cn.hutool.core.bean.BeanUtil;
import io.swagger.annotations.ApiModelProperty;
import cn.hutool.core.bean.copier.CopyOptions;
import org.hibernate.annotations.CreationTimestamp;
import org.hibernate.annotations.UpdateTimestamp;

import javax.persistence.*;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;
import java.sql.Timestamp;
import java.io.Serializable;

/**
* @website https://el-admin.vip
* @description /
* @author mcx
* @date 2022-03-17
**/
@Entity
@Data
@Table(name="account")
public class Account implements Serializable {

    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Column(name = "id")
    @ApiModelProperty(value = "编号")
    private Integer id;

    @Column(name = "status",nullable = false)
    @NotNull
    @ApiModelProperty(value = "状态")
    private Integer status;

    @Column(name = "username",nullable = false)
    @NotBlank
    @ApiModelProperty(value = "用户名")
    private String username;

    @Column(name = "password",nullable = false)
    @NotBlank
    @ApiModelProperty(value = "密码")
    private String password;

    @Column(name = "phone")
    @ApiModelProperty(value = "手机")
    private String phone;

    @Column(name = "emall")
    @ApiModelProperty(value = "邮箱")
    private String emall;

    @Column(name = "last_login_server_id")
    @ApiModelProperty(value = "最后登录服务器Id")
    private Integer lastLoginServerId;

    @Column(name = "last_login_server_name")
    @ApiModelProperty(value = "最后登录服务器名称")
    private String lastLoginServerName;

    @Column(name = "last_login_server_time")
    @ApiModelProperty(value = "最后登录服务器时间")
    private Timestamp lastLoginServerTime;

    @Column(name = "last_login_role_id")
    @ApiModelProperty(value = "最后登录角色Id")
    private Integer lastLoginRoleId;

    @Column(name = "last_login_role_nick_name")
    @ApiModelProperty(value = "最后登录角色名称")
    private String lastLoginRoleNickName;

    @Column(name = "createtime",nullable = false)
    @NotNull
    @CreationTimestamp
    @ApiModelProperty(value = "创建时间")
    private Timestamp createtime;

    @Column(name = "updatetime")
    @UpdateTimestamp
    @ApiModelProperty(value = "更新时间")
    private Timestamp updatetime;

    @Column(name = "device_identifier")
    @ApiModelProperty(value = "设备标志")
    private String deviceIdentifier;

    @Column(name = "device_model")
    @ApiModelProperty(value = "设备型号")
    private String deviceModel;

    public void copy(Account source){
        BeanUtil.copyProperties(source,this, CopyOptions.create().setIgnoreNullValue(true));
    }
}